package org.xdq.观察者模式;

public class Goods extends Subject {

    private int price;

    public Goods(int price){
        this.price = price;
    }


    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        int priceVar = price-this.price;//价格的变化量
        this.price = price;
        if(priceVar!=0)this.notifyAllObservers(priceVar);
    }
}
